#ifndef SEVENSEGMENTVIEW_HPP
#define SEVENSEGMENTVIEW_HPP

#include <QDockWidget>
#include <QGraphicsPolygonItem>
#include <QGraphicsEllipseItem>

#include "diagramscene.hpp"
#include "register.hpp"
#include "registerview.hpp"

namespace Ui {
    class SevenSegmentView;
}

/**
* @brief Representing the value of the connected Register
* @details This GUI-element shows the value of the connected register binary, decimal and hexadecimal number.
* It also shows a sevensegmentdisplay. The segments are connected in the following way: \n
* bit0 --> a, bit1 --> b, ..., bit7 --> dot
*
* @class SevenSegmentView sevensegmentview.hpp "sevensegmentview.hpp"
*/
class SevenSegmentView : public QDockWidget {
    Q_OBJECT
public:
    /**
    * @brief Constructor for SevenSegmentView
    *
    * @fn SevenSegmentView(RegisterView *regView, QWidget *parent = 0)
    * @param regView
    * @param parent
    */
    SevenSegmentView(RegisterView *regView, QWidget *parent = 0);

    /**
    * @brief Destructor for SevenSegmentView
    *
    * @fn ~SevenSegmentView()
    */
    ~SevenSegmentView();

protected:
    /**
    * @brief Action on ChangeEvent
    *
    * @fn void changeEvent(QEvent *e)
    * @param e
    */
    void changeEvent(QEvent *e);

private:
    Ui::SevenSegmentView *ui;
    int bank;
    int address;
    RegisterView *regView;
    DiagramScene *diagramScene;
    QGraphicsPolygonItem *segmentA;
    QGraphicsPolygonItem *segmentB;
    QGraphicsPolygonItem *segmentC;
    QGraphicsPolygonItem *segmentD;
    QGraphicsPolygonItem *segmentE;
    QGraphicsPolygonItem *segmentF;
    QGraphicsPolygonItem *segmentG;
    QGraphicsEllipseItem *segmentDot;

    void show(Register *reg);

private slots:
    void on_cb_ConnectTo_Bank0_currentIndexChanged(int index);
    void on_cb_ConnectTo_Bank1_currentIndexChanged(int index);
    void on_cb_ConnectTo_Special_currentIndexChanged(int index);
    void on_rad_Bank0_toggled(bool state);
    void on_rad_Bank1_toggled(bool state);
    void on_rad_Special_toggled(bool state);

public slots:
    void onRegisterChanged(Register *reg);
};

#endif // SEVENSEGMENTVIEW_HPP
